package bulider
import groovy.xml.MarkupBuilder
persons=["yaozhen":"friends","pengle":"colleague","zhouhang":"romate"]
def writer = new StringWriter()
def builder = new MarkupBuilder(writer) //生成器
builder.persons {
    persons.each {k,v->
        //指定名称是属性,不指定是值,值只能有一个
        person(name:k,v)
    }
}
println writer